const token = 'token';

export default {
  // eslint-disable-next-line no-unused-vars
  setToken(v) {
    sessionStorage.setItem(token, v);
  },

  getToken() {
    return sessionStorage.getItem(token);
  },

  clearToken() {
    sessionStorage.removeItem(token);
  },
  setItem(key, value) {
    sessionStorage.setItem(key, JSON.stringify(value));
  },
  getItem(key) {
    let obj = sessionStorage.getItem(key);
    if (obj && (obj.startsWith('{') || obj.startsWith('['))) {
      obj = JSON.parse(obj);
    }
    return obj;
  },
  clearItem(key) {
    sessionStorage.removeItem(key);
  },
};
